home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / GETCHAR.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  384 b   |  16 lines

  1. /*  getchar.c, from p.442 of Turbo C Bible  */
  2. #include <stdio.h>
  3. main()
  4. {
  5.     int i, c;
  6.     char buffer[81];
  7.     printf("Enter a line (end with a return):\n");
  8.     c = getchar();
  9.     for (i = 0; (i < 80) && (c != '\n'); i++)
  10.     {
  11.     buffer[i] = c;
  12.     c = getchar();
  13.     }
  14.     buffer[i] = '\0';        /*  to make a C-style string  */
  15.     printf("You entered: %s\n", buffer);
  16. }